package cn.zy.tools;

import java.security.MessageDigest;

public class Utils {
	public static int computeFast(int n) {
		if (n <= 0)
			return 0;
		long result = 1;
		long helper = 2;
		int m = n;
		while (m > 0) {
			if ((m & 1) == 1)
				result = (result * helper) % n;
			helper = ((helper % n) * (helper % n)) % n;
			m = m >> 1;
		}
		return (int) result;
	}

	
	//md5加密图片地址
	public static String md5(String s) throws Exception {
		MessageDigest md = MessageDigest.getInstance("MD5");

		md.update(s.getBytes());

		byte digest[] = md.digest();
		StringBuffer result = new StringBuffer();

		for (int i = 0; i < digest.length; i++) {
			result.append(Integer.toHexString(0xFF & digest[i]));
		}

		return (result.toString());
	}

}
